package com.yunji.ylexpiration.util;

public class SimpleResponse {
    //响应是否成功
    private boolean success;
    //响应出去的数据
    private Object data;
    //错误代码
    private int errCode;
    //错误信息
    private String errMsg;
    //错误描述
    private String errDesc;


    //响应成功，并附带数据
    public SimpleResponse(Object data){
        this.success = true;
        this.data = data;
    }
    public static SimpleResponse ok(Object data){
        return new SimpleResponse(data);
    }
    //成功,不附带数据
    public SimpleResponse(){
        this.success = true;
    }
    public static SimpleResponse ok(){
        return new SimpleResponse();
    }
    //响应失败
    public SimpleResponse(int errCode,String errMsg,String errDesc){
        this.success = false;
        this.errCode = errCode;
        this.errMsg = errMsg;
        this.errDesc = errDesc;
    }

    public static SimpleResponse error(int errCode,String errMsg,String errDesc){
        return new SimpleResponse(errCode,errMsg,errDesc);
    }
    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public int getErrCode() {
        return errCode;
    }

    public void setErrCode(int errCode) {
        this.errCode = errCode;
    }

    public String getErrMsg() {
        return errMsg;
    }

    public void setErrMsg(String errMsg) {
        this.errMsg = errMsg;
    }

    public String getErrDesc() {
        return errDesc;
    }

    public void setErrDesc(String errDesc) {
        this.errDesc = errDesc;
    }}
